package com.hermes.comics.data;

import android.util.AndroidRuntimeException;

public enum SerieTag {
  KEY("Key", 0),
  TITLE("Title", 1),
  PUBLISHER("Publisher", 2),
  AUTHOR("Author", 3),
  CATEGORY("Category", 4),
  NOTE("Note", 5),
  LANGUAGE("Language", 6),
  GENRE("Genre", 7),
  FORMAT("Format", 8),
  UNREVIEWED("Unreviewed", 9, true);

  private String title;
  private int index;
  private boolean isBoolValue;

  private SerieTag(String title, int index) {
    this(title, index, false);
  }

  private SerieTag(String title, int index, boolean isBoolValue) {
    this.title = title;
    this.index = index;
    this.isBoolValue = isBoolValue;
  }

  public boolean isBoolValue() {
    return isBoolValue;
  }

  public int index() {
    return index;
  }

  public String title() {
    return title;
  }

  public String value(Serie serie) {
    return serie.getTagValue(this);
  }

  @Override
  public String toString() {
    return name().toLowerCase();
  }

  public static SerieTag getTagByString(String tagString) {
    try {
      return Enum.valueOf(SerieTag.class, tagString.toUpperCase());
    } catch (Exception e) {
      throw new AndroidRuntimeException("Tag " + tagString + " is not registered. See SerieTag.");
    }
  }
}
